import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 沈明月
 * Date: 2022-11-07
 * Time: 12:29
 */
public class TestTwo {
//奇数位于偶数之前
//调整数组顺序使得奇数位于偶数之前。调整之后，不关心大小顺序。
//如数组：[1,2,3,4,5,6]
//调整后可能是：[1, 5, 3, 4, 2, 6]
    public static int [] func(int[] array){
        int left = 0;
        int right = array.length-1;
        while(left< right) {
            while(right > left && array[left]%2 != 0){
                left++;
            }
            while(right > left && array[right]%2 == 0){
                right--;
            }
            int tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
        }
        return array;
    }
    public static void main1(String[] args) {
        int [] array = new int[]{1,2,3,4,5,6};
        //进行交换：
        func(array);
        System.out.println(Arrays.toString(array));
    }
}
